home *** CD-ROM | disk | FTP | other *** search
- /* $Header: C:/SRC/MOUSE/PVCS/GMICE.C_V 1.0 12 Jun 1989 21:27:52 $
- Dwight N. Tovey (Adapted from the July/August 1988 issue of TURBO TECHNIX)
-
- Illustrates the default graphics mouse cursor, plus the four
- from GMOUSCUR.H
- -----------------------------------------------------------------------------
-
- $Log: C:/SRC/MOUSE/PVCS/GMICE.C_V $
- /*
- /* Rev 1.0 12 Jun 1989 21:27:52
- /* Initial revision.
- */
-
- /* INCLUDES and DEFINES */
- #include <stdio.h>
- #include <dos.h>
- #include <graph.h>
- #include <stdlib.h>
-
- #include "mouse.h"
- #include "gmouscur.h"
-
- #ifndef TRUE
- #define TRUE -1
- #define FALSE 0
- #endif
-
- #define EVENTMASK 0x54 /* Event when any mouse button released */
- #define MAX_X 80 /* Max number of columns (text output). */
- #define MAX_Y 25 /* Max number of rows (text output). */
-
- /* LOCAL PROTOTYPES */
- void demo ( GCURSREC, char* );
- void graphic_screen ( char* );
- void identify ( char* );
- void cleanup ( void );
- void initGCurs ( void );
- void far handler( );
-
- /* GLOBALS */
- union REGS reg;
- char path [] = "C:\SRC\MOUSE";
- struct videoconfig CONFIG;
- LocRec *M_LEFT, *M_RIGHT;
-
- /* Global mouse event record */
- EVENTREC theEvents;
-
- /****** M A I N ******/
- void main ()
- {
- resetRec *theMouse;
- void far *h_ptr; /* Pointer to handler function. */
-
- /* Set up for run */
- initGCurs(); /* Initialize the cursor images. */
- onexit( cleanup );
- theMouse = m_reset(); /* Reset the mouse. */
- if ( theMouse->exists )
- { /* Install handler. */
- h_ptr = handler;
- m_inst_task( EVENTMASK, FP_SEG( h_ptr ), FP_OFF( h_ptr ) );
-
- /* Show default cursor. */
- graphic_screen( "Default cursor" );
- m_show(); /* Turn on cursor. */
- theEvents.flag = 0;
- while( theEvents.flag == 0 ); /* Wait for click. */
-
- /* Show the custom cursors */
- demo( check, "Check" );
- demo( arrow, "Left arrow" );
- demo( cross, "Cross" );
- demo( hand, "Pointing Hand" );
- demo( iBeam, "I-Beam" );
- theMouse = m_reset();
- }
- }
-
-
- /****** C L E A N U P ******/
- void cleanup()
- {
- _setvideomode( _DEFAULTMODE );
- }
-
-
- /****** D E M O ******/
- void demo ( GCURSREC cursor, char title[] ) /* Show graphics cursor */
- {
- struct SREGS sr;
-
- identify( title );
- segread( &sr );
- m_graph_cursor( cursor.hotX, cursor.hotY, sr.ds,
- (unsigned) (cursor.image) );
-
- theEvents.flag = 0;
- while( theEvents.flag == 0 ); /* Wait for click. */
-
- }
-
- /****** G R A P H I C __ S C R E E N ******/
- void graphic_screen( char title[] ) /* Set up graphics screen. */
- {
- int x, y;
- char prompt[30];
-
- if ( _setvideomode( _HRESBW ) != 0 )
- {
- _getvideoconfig( &CONFIG );
- identify( title );
- strcpy( prompt, "Click left button to continue");
- x = (MAX_X - strlen(prompt)) / 2;
- y = MAX_Y - 20;
- _settextposition( y, x );
- _outtext( prompt );
-
- /* Draw rectangle as backdrop for cursor */
- _setcolor( 1 );
- x = CONFIG.numxpixels / 2 - 50;
- y = CONFIG.numypixels / 2 - 50;
- _rectangle( _GFILLINTERIOR, x, y, x + 100, y + 100 );
- }
- }
-
-
- /****** I D E N T I F Y ******/
- void identify( char *title )
- {
- int x;
-
- _setviewport( 0, 0, CONFIG.numxpixels, 30 );
- _clearscreen(_GVIEWPORT);
- x = (MAX_X - strlen( title)) / 2;
- _settextposition( 0, x );
- _outtext( title );
- _setviewport( 0, 0, CONFIG.numxpixels, CONFIG.numypixels );
- }
-
-
- /****** I N I T G C U R S ******/
- void initGCurs ( void ) /* Initialize ptrs in cursor descriptors. */
- {
- check.image = checkIm;
- arrow.image = LArrIm;
- cross.image = crossIm;
- hand.image = handIm;
- iBeam.image = iBeamIm;
- }
-